package require tcltest
package require Expect

namespace eval ::simulator::test {
  namespace import ::tcltest::*

  variable BEFORE {
    catch { unset result }
    spawn mkdir -p /home/launch/.kubesim/settings/
    set env(SIMULATOR_TF_DIR) "./test/fixtures/noop-tf-dir"
    set env(SIMULATOR_STATE_BUCKET) "dummy-test-bucket"
    set env(SIMULATOR_CLI_TEST_OUTPUT) "./test/test.debug"
  }

  variable AFTER {
    unset env(SIMULATOR_TF_DIR)
    unset env(SIMULATOR_CLI_TEST_OUTPUT)
  }

  test infra_create_prints_ok {
    Test: simulator infra create
  } -body {
    spawn "simulator" "infra" "create"
    expect eof
    catch wait result
    if {[lindex $result 3] != 0} {
      set result 0
    } else {
      set result 1
    }
  } -setup $BEFORE -cleanup $AFTER -result 1

  # test infra_status_prints_ok {
  #   Test: simulator infra status
  # } -body {
  #   spawn "simulator" "infra" "status"
  #   expect "testing = testing" { set result 1 } default { set result 0 }
  # } -setup $BEFORE -cleanup $AFTER -result 1


  cleanupTests 1
}

# vim: ft=tcl

